<template>
	<view class="page-view">
		<navBar title="维修确认"></navBar>
		<handling class="handling-view" :text="text" @statusdetails="statusdetails"></handling>
		<view class="w-100% h-1rpx" style="background-color: #E7ECED;"></view>
		<view class="table-list">
			<u-table align="left" v-if="status == 1">
				<u-tr class="u-tr h-80rpx">
					<u-th width="24%" class="u-th ">设备编号</u-th>
					<u-th width="30%" class="u-th ">设备名称</u-th>
					<u-th width="23%" class="u-th ">工序描述</u-th>
					<u-th width="24%" class="u-th ">维修状态</u-th>
					<u-th v-if="status==2" width="24%" class="u-th ">主管确认状态</u-th>
				</u-tr>
				<u-tr class="u-tr h-96rpx" v-for="(item, index) in dataList.items" :key="item.id" @click="goConfirm(item)">
					<u-td width="24%" class="u-td ">{{ item.barcode }}</u-td>
					<u-td width="30%" class="u-td ">{{ item.equpName }}</u-td>
					<u-td width="23%" class="u-td ">{{ item.processDesc }}</u-td>
					<u-td width="24%" class="u-td ">{{ item.repairStatus==1?'未维修':'已维修' }}</u-td>
					<u-td v-if="status==2" width="24%" class="u-td ">{{ item.repairStatus==1?'未确认':'已确认' }}</u-td>
				</u-tr>
			</u-table>
			<u-table align="left" v-else>
				<u-tr class="u-tr h-80rpx">
					<u-th width="20%" class="u-th ">设备编号</u-th>
					<u-th width="20%" class="u-th ">设备名称</u-th>
					<u-th width="20%" class="u-th ">工序描述</u-th>
					<u-th width="20%" class="u-th ">维修状态</u-th>
					<u-th width="20%" class="u-th ">主管确认状态</u-th>
				</u-tr>
				<u-tr class="u-tr h-96rpx" v-for="(item, index) in dataList.items" :key="item.id" @click="goConfirm(item)">
					<u-td width="20%" class="u-td ">{{ item.barcode }}</u-td>
					<u-td width="20%" class="u-td ">{{ item.equpName }}</u-td>
					<u-td width="20%" class="u-td ">{{ item.processDesc }}</u-td>
					<u-td width="20%" class="u-td ">{{ item.repairStatus==1?'未维修':'已维修' }}</u-td>
					<u-td width="20%" class="u-td ">{{ item.managerStatus }}</u-td>
				</u-tr>
			</u-table>
			<view v-if="dataList.items.length === 0" class="flex-center mt-32rpx">
				—— 暂无数据 ——
			</view>
		</view>

	</view>
</template>

<script lang="ts" setup>
import navBar from '@/components/navbar.vue'
import handling from '@/components/handling.vue'
import { getManagerList } from '@/common/api/equpManage'
import { ref,reactive,onMounted } from 'vue'
const dataList = reactive({items:[]})
const text = ref<any>({
	text1: '待处理',
	text2: '已处理'
})
const status = ref<number>(1)
const statusdetails = (val : any) => {
	status.value = val;
	getList();
}
onMounted(()=>{
	getList();
})
const getList = ()=>{
	getManagerList({status:status.value}).then(res=>{
		dataList.items = res
	})
}
// 维修确认
const goConfirm = (item:any)=>{
	uni.navigateTo({
		url: '/pages/RepairConfirm/confirmRepair?barcode='+item.barcode,
	});
}
</script>

<style lang="scss" scoped>
.handling-view{
	background-color: #fff;
}
.table-list{
	background-color: #fff;
	padding:32rpx;
	.u-th{
		font-size: 26rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #1E1F22;
		padding-left: 24rpx !important;
	}
	.u-td{
		font-size: 26rpx !important;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #4B4D55 !important;
		padding-left: 24rpx !important;
	}
	.u-tr{
		.u-td:last-child{
			text-align: right !important;
			padding-right: 32rpx !important;
		}
	}
}
</style>
